/**
 * Copyright 2024 The coretext Authors. All Rights Reserved.
 */
import { IBlockBuilder } from './IBlockBuilder';

export class BlockProvider {
  private static _instance: BlockProvider;

  private blockBuilder: IBlockBuilder;

  private constructor() {
  }

  static getInstance() {
    if (!this._instance) {
      this._instance = new BlockProvider();
    }
    return this._instance;
  }

  getBlockMaker(): IBlockBuilder {
    if (!this.blockBuilder) {
      throw "please set blockMaker first!";
    }
    return this.blockBuilder;
  }

  setBlockMaker(blockBuilder: IBlockBuilder) {
    this.blockBuilder = blockBuilder;
  }
}